package com.whcoding.designpatterns.pattern.strategy;

/**
 * @program: spring-boot-learning
 * @description: 环境角色类：
 * @author: whcoding
 * @create: 2022-09-20 20:03
 **/
public class BookVO {

	/**
	 * 图书名称
	 */
	private String name;

	/**
	 * 折扣类型
	 */
	private AbstractDiscountStrategy strategy;

	public BookVO(String name, AbstractDiscountStrategy strategy) {
		this.name = name;
		this.strategy = strategy;
	}

	/**
	 * Sets the strategy
	 *
	 * @param strategy strategy
	 */
	public void setStrategy(AbstractDiscountStrategy strategy) {
		this.strategy = strategy;
	}

	public void getDiscount() {
		System.out.println("图书名称：《" + name + "》，折扣算法为：" + strategy.getClass() + "，折扣价格为：" + strategy.calcDiscount());
	}
}
